<template>
    <van-address-edit 
        show-set-default
        :area-list="areaList"
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        :address-info="address"
        @save="save"
    />
</template>

<script setup>
    //show-set-default 设置默认滚轮框
    //引入地区数据
    import { areaList } from '@vant/area-data'
    const {proxy} = getCurrentInstance()

    let address = ref({
    })
    //添加收获地址的方法
    const save = async (values) => {
        //封装数据
        let data = {
            busid:proxy.$business.value.id,
            code:values.areaCode,
            mobile:values.tel,
            consignee:values.name,
            address:values.addressDetail,
            status:values.isDefault?1:0
        }
        //发送请求
        var result = await proxy.$POST({
            url:'/address/add',
            params:data
        })
        if(result.code=="0"){
            proxy.$fail(result.msg);
            return false
        }
        proxy.$success({
            message:result.msg,
            duration:1000,
            onClose: () => proxy.$router.go(-1)
        })

        
    }
</script>